package com.user.applaction;

import java.io.InputStream;

import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

public class SessionManager {
	private static SessionManager manager = new SessionManager();
	private SqlSessionFactory factory;

	private SessionManager() {
		String congfig = "mybatis.xml";
		InputStream is = UserApp.class.getClassLoader().getResourceAsStream(congfig);
		factory = new SqlSessionFactoryBuilder().build(is);
	}

	public static SessionManager getInstance() {
		return manager;
	}

	public SqlSession getSession() {
		return factory.openSession();
	}
}
